<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>breadcrumbs</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th bgcolor="#70b0f0" class="navbar-select"
          >&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Module&nbsp;breadcrumbs
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript: void(0);" class="privatelink"
    onclick="toggle_private();">hide private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="breadcrumbs-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="breadcrumbs-module.html">Module breadcrumbs</a></h1>
<pre class="py-src">
<span class="py-lineno"> 1</span>  <span class="py-line"><span class="py-docstring">"""</span> </span>
<span class="py-lineno"> 2</span>  <span class="py-line"><span class="py-docstring">module the supplies bread crumb type navigation information</span> </span>
<span class="py-lineno"> 3</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno"> 4</span>  <span class="py-line"><span class="py-docstring">breadcrumbs.py is a derivative of http://docs.turbogears.org/1.0/BreadCrumb</span> </span>
<span class="py-lineno"> 5</span>  <span class="py-line"><span class="py-docstring">with additional guidances from Marco Mariani &lt;marco at sferacarta dot com&gt; via</span> </span>
<span class="py-lineno"> 6</span>  <span class="py-line"><span class="py-docstring">the TG list.</span> </span>
<span class="py-lineno"> 7</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno"> 8</span>  <span class="py-line"><span class="py-docstring">this module makes no assumptions about the types of controllers or other </span> </span>
<span class="py-lineno"> 9</span>  <span class="py-line"><span class="py-docstring">imports.  Add it to your project, then import it in your controllers.py with::</span> </span>
<span class="py-lineno">10</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">11</span>  <span class="py-line"><span class="py-docstring">    import breadcrumbs</span> </span>
<span class="py-lineno">12</span>  <span class="py-line"><span class="py-docstring">  </span> </span>
<span class="py-lineno">13</span>  <span class="py-line"><span class="py-docstring">Next modify your template by adding the following template snippet (assumes kid </span> </span>
<span class="py-lineno">14</span>  <span class="py-line"><span class="py-docstring">templating)::</span> </span>
<span class="py-lineno">15</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">16</span>  <span class="py-line"><span class="py-docstring">    &lt;div id="navbar"&gt;</span> </span>
<span class="py-lineno">17</span>  <span class="py-line"><span class="py-docstring">        &lt;span py:for="breadcrumbURL,breadcrumbName in tg.breadcrumbs()"&gt;</span> </span>
<span class="py-lineno">18</span>  <span class="py-line"><span class="py-docstring">            &lt;a class="menu" href="${breadcrumbURL}"&gt;${breadcrumbName}&lt;/a&gt;</span> </span>
<span class="py-lineno">19</span>  <span class="py-line"><span class="py-docstring">        &lt;/span&gt;</span> </span>
<span class="py-lineno">20</span>  <span class="py-line"><span class="py-docstring">    &lt;/div&gt;</span> </span>
<span class="py-lineno">21</span>  <span class="py-line"><span class="py-docstring">"""</span> </span>
<span class="py-lineno">22</span>  <span class="py-line"><span id="link-0" class="py-name"><a title="breadcrumbs.__revision__" class="py-name" href="#" onclick="doclink('link-0', '__revision__', 'Variable breadcrumbs.__revision__=breadcrumbs-module.html#__revision__'); return false;">__revision__</a></span></span> <span class="py-op">=</span> <span class="py-string">"$Rev: 3 $"</span> </span>
<span class="py-lineno">23</span>  <span class="py-line"><span class="py-keyword">import</span> <span class="py-name">turbogears</span> <span class="py-name">as</span> <span class="py-name">tg</span> </span>
<span class="py-lineno">24</span>  <span class="py-line"><span class="py-keyword">import</span> <span class="py-name">cherrypy</span> </span>
<span class="py-lineno">25</span>  <span class="py-line"> </span>
<a name="breadcrumbs"></a><div id="breadcrumbs-def"><span class="py-lineno">26</span> <a class="py-toggle" href="#" id="breadcrumbs-toggle" onclick="toggle('breadcrumbs'); return false;">-</a><span class="py-line"><span class="py-keyword">def</span> <a class="py-def-name" href="breadcrumbs-module.html#breadcrumbs">breadcrumbs</a><span class="py-op">(</span><span class="py-op">)</span><span class="py-op">:</span> </span>
</div><div id="breadcrumbs-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="breadcrumbs-expanded"><span class="py-lineno">27</span>  <span class="py-line">    <span class="py-docstring">"""</span> </span>
<span class="py-lineno">28</span>  <span class="py-line"><span class="py-docstring">    Return link information for constructing bread crumb navigation.</span> </span>
<span class="py-lineno">29</span>  <span class="py-line"><span class="py-docstring">    </span> </span>
<span class="py-lineno">30</span>  <span class="py-line"><span class="py-docstring">    @rtype: list</span> </span>
<span class="py-lineno">31</span>  <span class="py-line"><span class="py-docstring">    @return: a list of items(list) consisting of [breadcrumbURL, breadcrumbName]</span> </span>
<span class="py-lineno">32</span>  <span class="py-line"><span class="py-docstring">    """</span> </span>
<span class="py-lineno">33</span>  <span class="py-line">    <span class="py-name">cherry_trail</span> <span class="py-op">=</span> <span class="py-name">cherrypy</span><span class="py-op">.</span><span class="py-name">_cputil</span><span class="py-op">.</span><span class="py-name">get_object_trail</span><span class="py-op">(</span><span class="py-op">)</span> </span>
<span class="py-lineno">34</span>  <span class="py-line">    <span class="py-comment">#normalize the root path using tg.url()</span> </span>
<span class="py-lineno">35</span>  <span class="py-line"><span class="py-comment"></span>    <span class="py-name">href</span> <span class="py-op">=</span> <span class="py-name">tg</span><span class="py-op">.</span><span class="py-name">url</span><span class="py-op">(</span><span class="py-string">'/'</span><span class="py-op">)</span> </span>
<span class="py-lineno">36</span>  <span class="py-line">    <span class="py-name">crumbs</span> <span class="py-op">=</span> <span class="py-op">[</span><span class="py-op">(</span><span class="py-name">href</span><span class="py-op">,</span> <span class="py-string">'home'</span><span class="py-op">)</span><span class="py-op">]</span> </span>
<span class="py-lineno">37</span>  <span class="py-line">    <span class="py-keyword">for</span> <span class="py-name">item</span> <span class="py-keyword">in</span> <span class="py-name">cherry_trail</span><span class="py-op">:</span> </span>
<span class="py-lineno">38</span>  <span class="py-line">        <span class="py-comment"># item[0] is the name you use in the URL to access the controller.</span> </span>
<span class="py-lineno">39</span>  <span class="py-line"><span class="py-comment"></span>        <span class="py-comment"># item[1] is the actual controller</span> </span>
<span class="py-lineno">40</span>  <span class="py-line"><span class="py-comment"></span>        <span class="py-keyword">if</span> <span class="py-name">item</span><span class="py-op">[</span><span class="py-number">1</span><span class="py-op">]</span> <span class="py-keyword">is</span> <span class="py-keyword">not</span> <span class="py-name">None</span><span class="py-op">:</span> </span>
<span class="py-lineno">41</span>  <span class="py-line">            <span class="py-keyword">if</span> <span class="py-name">item</span><span class="py-op">[</span><span class="py-number">0</span><span class="py-op">]</span> <span class="py-op">!=</span> <span class="py-string">'root'</span> <span class="py-keyword">and</span> <span class="py-name">item</span><span class="py-op">[</span><span class="py-number">0</span><span class="py-op">]</span> <span class="py-op">!=</span> <span class="py-string">'index'</span><span class="py-op">:</span> </span>
<span class="py-lineno">42</span>  <span class="py-line">                <span class="py-name">href</span> <span class="py-op">=</span> <span class="py-name">tg</span><span class="py-op">.</span><span class="py-name">url</span><span class="py-op">(</span><span class="py-string">"%s%s/"</span> <span class="py-op">%</span> <span class="py-op">(</span><span class="py-name">href</span><span class="py-op">,</span> <span class="py-name">item</span><span class="py-op">[</span><span class="py-number">0</span><span class="py-op">]</span><span class="py-op">)</span><span class="py-op">)</span> </span>
<span class="py-lineno">43</span>  <span class="py-line">                <span class="py-name">crumbs</span><span class="py-op">.</span><span class="py-name">append</span><span class="py-op">(</span><span class="py-op">[</span><span class="py-name">href</span><span class="py-op">,</span> <span class="py-name">item</span><span class="py-op">[</span><span class="py-number">0</span><span class="py-op">]</span><span class="py-op">]</span><span class="py-op">)</span> </span>
<span class="py-lineno">44</span>  <span class="py-line">    <span class="py-keyword">return</span> <span class="py-name">crumbs</span> </span>
</div><span class="py-lineno">45</span>  <span class="py-line"> </span>
<a name="addvars"></a><div id="addvars-def"><span class="py-lineno">46</span> <a class="py-toggle" href="#" id="addvars-toggle" onclick="toggle('addvars'); return false;">-</a><span class="py-line"><span class="py-keyword">def</span> <a class="py-def-name" href="breadcrumbs-module.html#addvars">addvars</a><span class="py-op">(</span><span class="py-param">tgvars</span><span class="py-op">)</span><span class="py-op">:</span> </span>
</div><div id="addvars-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="addvars-expanded"><span class="py-lineno">47</span>  <span class="py-line">    <span class="py-docstring">"""</span> </span>
<span class="py-lineno">48</span>  <span class="py-line"><span class="py-docstring">    function which adds an key:value pair to an existing dictionary -- in this case the </span> </span>
<span class="py-lineno">49</span>  <span class="py-line"><span class="py-docstring">    dictionary is the builtin TG standard variables</span> </span>
<span class="py-lineno">50</span>  <span class="py-line"><span class="py-docstring">    </span> </span>
<span class="py-lineno">51</span>  <span class="py-line"><span class="py-docstring">    @param  vars: the builtin TG standard variables dictionary</span> </span>
<span class="py-lineno">52</span>  <span class="py-line"><span class="py-docstring">    @type     vars: dictionary</span> </span>
<span class="py-lineno">53</span>  <span class="py-line"><span class="py-docstring">    </span> </span>
<span class="py-lineno">54</span>  <span class="py-line"><span class="py-docstring">    @rtype: None</span> </span>
<span class="py-lineno">55</span>  <span class="py-line"><span class="py-docstring">    """</span> </span>
<span class="py-lineno">56</span>  <span class="py-line">    <span class="py-name">tgvars</span><span class="py-op">[</span><span class="py-string">'breadcrumbs'</span><span class="py-op">]</span> <span class="py-op">=</span> <span id="link-1" class="py-name"><a title="breadcrumbs
breadcrumbs.breadcrumbs" class="py-name" href="#" onclick="doclink('link-1', 'breadcrumbs', 'Module breadcrumbs=breadcrumbs-module.html,Function breadcrumbs.breadcrumbs()=breadcrumbs-module.html#breadcrumbs'); return false;">breadcrumbs</a></span></span> </span>
</div><span class="py-lineno">57</span>  <span class="py-line"> </span>
<span class="py-lineno">58</span>  <span class="py-line"><span class="py-comment"># now update the built in TG standard variables</span> </span>
<span class="py-lineno">59</span>  <span class="py-line"><span class="py-comment"></span><span class="py-name">tg</span><span class="py-op">.</span><span class="py-name">view</span><span class="py-op">.</span><span class="py-name">variable_providers</span><span class="py-op">.</span><span class="py-name">append</span><span class="py-op">(</span><span id="link-2" class="py-name"><a title="breadcrumbs.addvars" class="py-name" href="#" onclick="doclink('link-2', 'addvars', 'Function breadcrumbs.addvars()=breadcrumbs-module.html#addvars'); return false;">addvars</a></span></span><span class="py-op">)</span> </span>
<span class="py-lineno">60</span>  <span class="py-line"> </span><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th bgcolor="#70b0f0" class="navbar-select"
          >&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">Generated by Epydoc
        3.0alpha3 on Tue Dec 19 00:03:15 2006</td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
